package com.szqhyxj.youxiangju.biz.receipt.receiptdetail;

import com.google.gson.annotations.SerializedName;
import com.szqhyxj.youxiangju.sys.BaseResult;
import com.szqhyxj.youxiangju.sys.RetrofitFacade;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

/**
 * Created by leung on 2018/11/23.
 */

public class ReceiptDetailModel {

    private interface ReceiptDetailService {
        @POST("trade/getDepositCard")
        Observable<BaseResult<String>> cardNo();

        //申请线上收款（获取验证码）
        @FormUrlEncoded
        @POST("online/receipt")
        Observable<BaseResult<OnlineSmsEntity>> onlineGetsms(
                @Field("channelCode") String channelCode,
                @Field("tradeCardId") String tradeCardId,
                @Field("amt") String amt,
                @Field("settleCardId") String settleCardId
        );

        //确定线上收款（验证码验证）
        @FormUrlEncoded
        @POST("online/receiptConfirm")
        Observable<BaseResult<ConfirmEntity>> receiptConfirm(
                @Field("channelCode") String channelCode,
                @Field("tradeCardId") String tradeCardId,
                @Field("settleCardId") String settleCardId,
                @Field("tradeNo") String tradeNo,
                @Field("confirmCode") String confirmCode
        );

    }

    public static Observable<BaseResult<String>> getCardNo() {
        return RetrofitFacade.Companion.getRetrofit().create(ReceiptDetailService.class).cardNo();
    }

    //线上收款获取验证码
    public static Observable<BaseResult<OnlineSmsEntity>> onlineGetsms(String channelCode, String tradeCardId, String amt, String settleCardId) {
        return RetrofitFacade.Companion.getMockretrofit().create(ReceiptDetailService.class).onlineGetsms(channelCode, tradeCardId, amt, settleCardId);

    }

    //线上收款确认
    public static Observable<BaseResult<ConfirmEntity>> receiptConfirm(String channelCode, String tradeCardId, String settleCardId, String tradeNo, String confirmCode) {
        return RetrofitFacade.Companion.getMockretrofit().create(ReceiptDetailService.class).receiptConfirm(channelCode, tradeCardId, settleCardId, tradeNo, confirmCode);
    }


    public class OnlineSmsEntity {

        @SerializedName("result")
        private String result;

        @SerializedName("orderNo")
        private String orderNo;

        @SerializedName("status")
        private String status;

        public void setResult(String result) {
            this.result = result;
        }

        public String getResult() {
            return result;
        }

        public void setOrderNo(String orderNo) {
            this.orderNo = orderNo;
        }

        public String getOrderNo() {
            return orderNo;
        }

        public void setStatus(String status) {
            this.status = status;
        }

        public String getStatus() {
            return status;
        }

        @Override
        public String toString() {
            return
                    "OnlineSmsEntity{" +
                            "result = '" + result + '\'' +
                            ",orderNo = '" + orderNo + '\'' +
                            ",status = '" + status + '\'' +
                            "}";
        }
    }

    public class ConfirmEntity{

        @SerializedName("msg")
        private String msg;

        @SerializedName("orderNo")
        private String orderNo;

        @SerializedName("topOrderNo")
        private Object topOrderNo;

        @SerializedName("status")
        private String status;

        public void setMsg(String msg){
            this.msg = msg;
        }

        public String getMsg(){
            return msg;
        }

        public void setOrderNo(String orderNo){
            this.orderNo = orderNo;
        }

        public String getOrderNo(){
            return orderNo;
        }

        public void setTopOrderNo(Object topOrderNo){
            this.topOrderNo = topOrderNo;
        }

        public Object getTopOrderNo(){
            return topOrderNo;
        }

        public void setStatus(String status){
            this.status = status;
        }

        public String getStatus(){
            return status;
        }

        @Override
        public String toString(){
            return
                    "ConfirmEntity{" +
                            "msg = '" + msg + '\'' +
                            ",orderNo = '" + orderNo + '\'' +
                            ",topOrderNo = '" + topOrderNo + '\'' +
                            ",status = '" + status + '\'' +
                            "}";
        }
    }
}
